﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;
using System.IO;

namespace SendAlert
{
  public class TrimitereMail
        {
            public static bool TrimiteMailReducere(string Nume, string AdresaEmail, string Mesaj)
            {
                MailMessage ma = new MailMessage();
                ma.Body = "Salut " + Nume + ",<br/><br/> Te informam ca: <br/>";
                ma.Body += Mesaj;
                ma.Body += "<br/>Multumim,<br/>Echipa cotrobaie.ro";
                ma.BodyEncoding = System.Text.Encoding.UTF8;
                ma.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
                ma.From = new MailAddress("cotrobaie@yahoo.com", "cotrobaie.cjb.net");
                ma.IsBodyHtml = true;
                ma.Priority = MailPriority.High;
                ma.Subject = "[cotrobaie.cjb.net] Reducere produs";
                ma.SubjectEncoding = System.Text.Encoding.UTF8;
                ma.To.Add(new MailAddress(AdresaEmail));
                
                SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com");
                smtp.Port = 587;
            
                smtp.Credentials = new System.Net.NetworkCredential("cotrobaie@yahoo.com", "3.14team");
                smtp.Timeout = 100000;//default e 100.000 adica 100 sec
                
                try { smtp.Send(ma); }
                catch { return false; }
                ma.Dispose();
                smtp.Dispose();
                return true;
            }        
       }
}
